﻿using System;
using System.Collections.Generic;
using System.Text;

namespace OrderExer
{
    //订单明细
    internal class OrderDetails
    {
        Customer customer;//客户对象
        Commodity commodity;//商品对象
        
        public OrderDetails() { }
        public OrderDetails(string cusname,string age,string comname,string date)
        {
            Customer = new Customer(cusname, age);
            Commodity = new Commodity(comname, date);
        }

        internal Customer Customer { get => customer; set => customer = value; }
        internal Commodity Commodity { get => commodity; set => commodity = value; }

        public override bool Equals(object obj)
        {
            return obj is OrderDetails details &&
                   EqualityComparer<Customer>.Default.Equals(Customer, details.Customer) &&
                   EqualityComparer<Commodity>.Default.Equals(Commodity, details.Commodity);
        }
        /*
        public override int GetHashCode()
        {
            return HashCode.Combine(Customer, Commodity);
        }
        */
        public override string ToString()
        {
            return " 客户信息：" + this.Customer.ToString() + ",商品信息：" + this.Commodity.ToString();
        }
    }
}
